package com.huang.consumer_mall.web;

import com.huang.consumer_mall.model.Saycommodity;
import com.huang.consumer_mall.service.SaycommodityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class SaycommodityController  {
    @Autowired
    protected SaycommodityService saycommodityService;

    @PostMapping("/api/saycommodity/findEvaluationList")
    public List<Saycommodity> findList(@RequestBody Saycommodity saycommodity){
        return saycommodityService.findList(saycommodity);
    }

    @PostMapping("/api/saycommodity/addEvaluation")
    public String insert(@RequestBody Saycommodity saycommodity){
        saycommodityService.insert(saycommodity);
        return "success";
    }

    @PostMapping("/api/saycommodity/deleteById")
    public String deleteById(@RequestBody Saycommodity saycommodity){
        saycommodityService.deleteById(saycommodity);
        return "success";
    }

    @PostMapping("/api/saycommodity/findisbuy")
    public String find(@RequestBody Saycommodity saycommodity){
        Saycommodity saycommodity1 = saycommodityService.find(saycommodity);
        if(saycommodity1 != null ){
            return "yes";
        }
        return "no";
    }
}
